<?php
/**
 * Copyright (c) 2006-2008, Julien PORTALIER
 * http://featherphp.googlecode.com/
 * 
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 */

/**
 * Controller to handle errors.
 */
class ErrorsController extends Controller
{
	protected $uses      = false;
	protected $layout    = 'error';
	protected $templates = 'errors';
	
	/**
	 * Renders an error.
	 * 
	 * @param $code Integer[optional] HTTP status code (defaults to 404).
	 * @param $action String[optional] Render a specific view.
	 * @param $data Array[optional]
	 */
	function show($code=404, $action=null, array $data=null)
	{
		HTTP::status($code);
		$this->code = $code;
		$this->page_title = preg_replace(':^HTTP/1.1 \d+ :', '', HTTP::get_status($code));
		
		if (!empty($data)) {
			$this->set($data);
		}
		$this->render(empty($action) ? $code : $action);
	}
}
?>